home *** CD-ROM | disk | FTP | other *** search
- $m10000 ! Compiler option to use
- ' only 10k of memory.
- LET tree1&=0 !RSC_TREE These Variables are
- LET setdate&=1 !Obj in #0 created by the Resource
- LET settime&=2 !Obj in #0 Constuction Set (RSC)
- LET setok&=3 !Obj in #0 and are written as a
- LET tree2&=1 !RSC_TREE *.LST file and merged
- LET viewdate&=1 !Obj in #1 into the program source
- LET viewtime&=2 !Obj in #1
- LET viewok&=3 !Obj in #1
- LET reset&=4 !Obj in #1
- IF RSRC_LOAD("SETTIME.RSC")=0 ! Find the RSC file
- ALERT 1,"SETTIME.RSC| NOT FOUND",1,"ABORT",button# ! Can't find it, notify
- ' the user.
- END ! Stop program
- ENDIF
- MODE 1 ! Set date format to U.S.
- ~RSRC_GADDR(0,tree1&,input%) ! Get the address of the
- ' first Object Tree.
- ' (input box)
- ~FORM_CENTER(input%,x%,y%,w%,h%) ! Center the input box
- ' on the screen. The
- ' nice thing about this
- ' is it does the
- ' calculation for each
- ' resolution for you.
- ~RSRC_GADDR(0,tree2&,output%) ! Get the address of the
- ' second Object Tree.
- ' (verification box)
- ~FORM_CENTER(output%,x%,y%,w%,h%) ! Center it
- GET x%,y%,x%+w%,y%+h%,rsc_screen_area$ ! Save what will be
- ' overwitten by the
- ' dialog box. It is up to
- ' the programer to put the
- ' screen back the way it
- ' was befor the box
- ' appeared.
- set_it: ! Major sin...using a GOTO
- @get_date_time ! What time is it now?
- CHAR{{OB_SPEC(input%,setdate&)}}=date_$ ! Move the current date
- CHAR{{OB_SPEC(input%,settime&)}}=time_$ ! and time into the dialog
- ' box.
- ~FORM_DIAL(1,0,0,0,0,x%,y%,w%,h%) ! This makes the box
- ' appear to expand from
- ' the center.
- ~OBJC_DRAW(input%,tree1&,1,x%,y%,w%,h%) ! Display the box
- ~FORM_DO(input%,0) ! This takes your input.
- ' believe it or not this
- ' one line does it all.
- ~OBJC_CHANGE(input%,setok&,0,x%,y%,w%,z%,0,1) ! We need to redraw the
- ' box in case we decide to
- ' reset the clock. If we
- ' reset this keeps the
- ' OK button from appearing
- ' filled.
- PUT x%,y%,rsc_screen_area$ ! Redraw original screen.
- ~FORM_DIAL(2,0,0,0,0,x%,y%,w%,h%) ! Now make the box
- ' disappear into the
- ' monitor (shrink).
- time_$=CHAR{{OB_SPEC(input%,settime&)}} ! Put the inputs into
- date_$=CHAR{{OB_SPEC(input%,setdate&)}} ! variables.
- ' ----------------------------------------------------------------------------
- month$=LEFT$(date_$,2)
- day$=MID$(date_$,3,2)
- year$=RIGHT$(date_$,2)
- date_$=month$+"/"+day$+"/"+year$
- hour$=LEFT$(time_$,2)
- minute$=MID$(time_$,3,2) ! Figure out the inputs
- ampm$=RIGHT$(time_$,1) ! and configure them for
- IF ampm$="A" OR ampm$="a" ! the SETTIME command
- IF hour$="12"
- hour$="00"
- ENDIF
- ELSE
- hour&=VAL(hour$)
- ADD hour&,12
- IF hour&=24
- hour$="12"
- ELSE
- hour$=STR$(hour&)
- ENDIF
- ENDIF
- time_$=hour$+":"+minute$+":"+"00"
- ' ----------------------------------------------------------------------------
- SETTIME time_$,date_$ ! Set the date and time
- ' If the inputs are not
- ' valid the date or time
- ' will not change, thus
- ' we have a reset option.
- @get_date_time ! What time is it now?
- CHAR{{OB_SPEC(output%,viewdate&)}}=date_$ ! Move the current date
- CHAR{{OB_SPEC(output%,viewtime&)}}=time_$ ! and time to the dialog
- ' box.
- ~FORM_DIAL(1,0,0,0,0,x%,y%,w%,h%) ! Expand box.
- ~OBJC_DRAW(output%,0,tree2&,x%,y%,w%,h%) ! Draw box.
- button&=FORM_DO(output%,0) ! Store button selected.
- ~OBJC_CHANGE(output%,button&,0,x%,y%,w%,z%,0,1) ! Restore button
- ' selected.
- PUT x%,y%,rsc_screen_area$ ! Redraw original screen.
- ~FORM_DIAL(2,0,0,0,0,x%,y%,w%,h%) ! Shrink box.
- IF button&=4 ! If reset was selected,
- GOTO set_it ! here it comes, -GOTO-
- ENDIF ! to reset date and time.
- ~RSRC_FREE() ! Important, you must
- ' ! return memory used by
- ' ! the RSRC_LOAD command
- ' ! to the system.
- END ! Stop program.
- '
- PROCEDURE get_date_time ! Since I need to get the
- ' date and time twice in
- ' the program flow I use
- ' this subroutine to do
- ' it.
- month$=LEFT$(DATE$,2)
- day$=MID$(DATE$,4,2) ! Set up the date for the
- year$=RIGHT$(DATE$,2) ! dialog box.
- date_$=month$+day$+year$
- hour$=LEFT$(TIME$,2) ! Set up the time for the
- minute$=MID$(TIME$,4,2) ! dialog box.
- hour&=VAL(hour$)
- IF hour&=0
- hour&=12
- ampm$="A"
- ELSE IF hour&=12
- ampm$="P"
- ELSE IF hour&>12
- SUB hour&,12
- ampm$="P"
- ELSE
- ampm$="A"
- ENDIF
- hour$=STR$(hour&)
- n&=LEN(hour$)
- IF n&=1
- hour$="0"+hour$
- ENDIF
- time_$=hour$+minute$+ampm$
- RETURN
-